//
//  PBRentDateController.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/3/16.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBRentDateController.h"
#import "PBChoosePayTypeController.h"

@interface PBRentDateController ()
@property (strong, nonatomic) IBOutlet UILabel *startLabel;
@property (strong, nonatomic) IBOutlet UILabel *endLabel;
@property (strong, nonatomic) IBOutlet UILabel *priceLabel;

@end

@implementation PBRentDateController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self configure];
}

- (void)configure {
    [self configureView];
    [self configureData];
}

- (void)configureView {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"YYYY年MM月dd日";
    // 数字时间戳转化为日期，如果为13位，则需要除以1000，或者去掉后3位
    NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:[[self.model.contractStart substringWithRange:NSMakeRange(0, 10)] doubleValue]];
    NSString *startTime = [formatter stringFromDate:startDate];
    NSDate *endDate = [NSDate dateWithTimeIntervalSince1970:[[self.model.contractEnd substringWithRange:NSMakeRange(0, 10)] doubleValue]];
    NSString *endTime = [formatter stringFromDate:endDate];
    self.startLabel.text = startTime;
    self.endLabel.text = endTime;
    self.priceLabel.text = [NSString stringWithFormat:@"%@元/月",self.model.rent];
}
- (void)configureData {
    
}

- (IBAction)nextStepButtonClick:(id)sender {
    PBChoosePayTypeController *vc = [[PBChoosePayTypeController alloc] init];
    vc.model = self.model;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - super
- (void)resetNavigationBarItems {
    [super resetNavigationBarItems];
    self.title = @"租期信息";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
